/*
 * Copyright (c) Beicaizs.com Inc.
 * All Rights Reserved.
 */
package com.zlb.envmodify.util;

import java.lang.reflect.Field;

/**
 * @Description
 * @ClassName ObjectUtil
 * @Author zhuliangbing
 * @Date 2024/6/24 9:00
 * @Version 0.0.1
 */
public class ObjectUtil {

    public static <T> T instanceForClass(Class<T> classz) {
        try {
            return classz.newInstance();
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    public static void setFiled(Object target, String fieldName, Object value) {
        try {
            Field declaredField = target.getClass().getDeclaredField(fieldName);
            declaredField.setAccessible(true);
            declaredField.set(target, value);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
}
